import 'package:flutter/material.dart';
import 'package:flutter_advanced_avatar/flutter_advanced_avatar.dart';
import 'package:flutter_tech_shop/src/context_extension.dart';
import 'package:flutter_tech_shop/src/screens/edit_address_page.dart';
import 'package:flutter_tech_shop/src/screens/submit_page.dart';
import 'package:flutter_tech_shop/src/widgets/setting_view/setting_view.dart';
import 'package:get/get.dart';

final addressController = Get.put(AddressController());

class ProfilePage extends StatelessWidget {
  const ProfilePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('个人信息'), centerTitle: true),
      body: Container(
          child: Column(
        children: [
          const Row(
            children: [
              SizedBox(width: 20),
              AdvancedAvatar(
                image: NetworkImage('https://i.pravatar.cc/200?img=1'),
              )
            ],
          ),
          Expanded(child: Obx(() => SettingView(data: [
            SettingInfoModel(title: '我的账号', value: '1850160433@qq.com'),
            SettingInfoModel(title: '我的收货地址', value: addressController.addresses[addressController.currentAddress.value].address!),
            SettingDividerModel(),
            SettingInfoModel(title: '帮助与反馈', value: ''),
          ], itemOnTap: (item) {
            switch(item.title) {
              case '帮助与反馈':
                context.push(const SubmitPage(title: '反馈', hintText: '请输入您的反馈意见'));
                break;
              case '我的收货地址':
                context.push(EditAddressPage());
              // context.push(const SubmitPage(title: '编辑收货地址', hintText: '请输入您的收货地址'));

                break;
              case '我的账号':
                context.push(const SubmitPage(title: '修改账号', hintText: '请重新输入您的账号'));
                break;
            }
          })))
        ],
      )),
    );
  }
}
